<%@ page import="bean.User" %>
<%@ page import="bean.Article" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="bean.Category" %>
<%@ page import="bean.Label" %><%--
  Created by IntelliJ IDEA.
  User: 蒋缇
  Date: 2020/10/19
  Time: 12:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page isThreadSafe="false" contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    User user=(User)session.getAttribute("user");
    ArrayList<Article> articleArrayList=(ArrayList<Article>)session.getAttribute("userArticles");
    ArrayList<Article> articleCollections=(ArrayList<Article>)session.getAttribute("userCollections");
    ArrayList<Article> articleLikes=(ArrayList<Article>)session.getAttribute("userLikes");
    ArrayList<Category> arrayCategories=(ArrayList<Category>)session.getAttribute("userCategories");
    ArrayList<Label> labels=(ArrayList<Label>)session.getAttribute("userLabels");
    ArrayList<Article> articles=(ArrayList<Article>)session.getAttribute("browseUserArticles");
    User browseUser=(User)session.getAttribute("browseUser");

%>
<html>
<head>
    <title>查看博主</title>
    <link rel="stylesheet"  href="css/bootstrap.min.css"/>
    <script src="js/jquery-3.1.1.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/allStyle.css">
</head>
<body>
<%--    导航条--%>
<div class="row">
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <%--                    TBLOG标签--%>
                <a class="navbar-brand" href="#">TBLOG</a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <%--                    主页链接--%>
                <ul class="nav navbar-nav">
                    <li><a href="websiteHomepage.jsp">首页🏠</a></li>
                    <%--                        下拉菜单--%>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">其他 <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="#">Action</a></li>
                            <li><a href="#">Another action</a></li>
                            <li><a href="#">Something else here</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">Separated link</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">One more separated link</a></li>
                        </ul>
                    </li>
                </ul>
                <%--                     搜索栏--%>
                <form class="navbar-form navbar-left">
                    <input type="text" id="searchContent" class="form-control" size="125" maxlength="200" placeholder="请输入您想查询的内容">
                    <div class="dropdown">
                        <%--                            搜索按钮--%>
                        <button id="dLabel" type="button" class="btn btn-danger" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            🔍
                            <span class="caret"></span>
                        </button>
                        <%--                          博客，博主搜索--%>
                        <ul class="dropdown-menu" aria-labelledby="dLabel">
                            <button type="button" class="btn btn-default" onclick="searchKey()">关键字搜索</button>
                            <button type="button" class="btn btn-default" onclick="searchUser()">博主搜索</button>
                            <button type="button" class="btn btn-default" onclick="searchSubfield()">分栏专类搜索</button>
                            <button type="button" class="btn btn-default" onclick="searchLabel()">标签搜索</button>
                        </ul>
                    </div>
                </form>
                <%--                    链接--%>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="writeBlogPage.jsp">创作中心</a></li>
                    <%--                        下拉菜单--%>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><img src="<%=user.getHeadPortrait().equals("")?"images/defaultHeadPortrait.jpg":user.getHeadPortrait()%>" alt="无法加载" class="img-circle" width="20px" height="20px"><span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="personalHompage.jsp">个人中心</a></li>
                            <li><a href="loginPage.jsp">账号设置</a></li>
                            <li><a href="forgetPage.jsp">找回密码</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="successPage.jsp">退出</a></li>
                        </ul>
                    </li>
                </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>
</div>
<div class="row">
    <div class="col-lg-3"></div>
    <div class="col-lg-6">
        <div class="panel panel-default">
            <div class="panel-body">
                <img src="<%=browseUser.getHeadPortrait().equals("")?"images/defaultHeadPortrait.jpg":browseUser.getHeadPortrait()%>" alt="无法加载" class="img-circle" width="40px" height="40px">
                <span>账号：<%=browseUser.getAccount()%> </span><span>年龄：<%=browseUser.getSign()%> </span><span>性别：<%=browseUser.getSex()%> </span><span>个性签名：<%=browseUser.getSign()%></span>
            </div>
        </div>
    </div>
    <div class="col-lg-3"></div>
</div>
<div class="row">
    <div class="col-lg-3"></div>
    <div class="col-lg-6">
        <div class="panel panel-default">
            <div class="panel-body">
                <ul class="list-group">
                    <%
                        for(Article article:articles){
                    %>
                    <li class="list-group-item" ondblclick="browseBlog('<%=article.getId()%>')">
                        <h4><%=article.getTitle()%></h4><hr><br><font style="font-size: 5px">作者：<%=article.getUser()%>时间：<%=article.getTime()%> 浏览数：<%=article.getViews()%>
                        类型：<%=article.getType()%></font></li>
                    <%
                        }
                    %>
                </ul>
            </div>
        </div>
    </div>
    <div class="col-lg-3"></div>
</div>
<script type="text/javascript">
    function browseBlog(id) {
        $.ajax({
                data: {'browseArticleId':id},
                dataType: 'text',
                type: 'post',
                url: '<%=basePath%>BrowseBlogServlet',
                success: function () {
                    window.location = "<%=basePath%>blogPage.jsp";
                },
                error: function () {
                    alert("查看失败");
                }
            }
        );
    }
</script>
</body>
</html>
